<?
include("../lib/config.php");
$nik 	= $HTTP_GET_VARS['nik'];
$op		= $HTTP_GET_VARS['op'];
$no		= $HTTP_GET_VARS['no'];

if($op == "edit"){
	$Faction = "../lib/update.php";
	$Vbutton = "Update";
	$query	= mssql_query("WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY Cert_Date) as No, *, CONVERT(CHAR(12), Cert_Date, 103) tgl_sertifikat, CONVERT(CHAR(12), Cert_Date_Exp, 103) tgl_kadaluarsa FROM MK_Certification WHERE NIK='$nik') SELECT * FROM limit Where No='$no' ",$conn);
	$row	= mssql_fetch_array($query);
}
else{
	$Faction = "../lib/save.php";
	$Vbutton = "Simpan";
}

include("../header.php");
?>
<script type="text/javascript">
	function LoadFocus(){
		document.forms[0].elements[0].focus();
	}
	
	MaskInput = function(f, m){
	function mask(e){
		var patterns = {"1": /[A-Z]/i, "2": /[0-9]/, "4": /[\xC0-\xFF]/i, "8": /./ },
			rules = { "a": 3, "A": 7, "9": 2, "C":5, "c": 1, "*": 8};
		function accept(c, rule){
			for(var i = 1, r = rules[rule] || 0; i <= r; i<<=1)
				if(r & i && patterns[i].test(c))
					break;
				return i <= r || c == rule;
		}
		var k, mC, r, c = String.fromCharCode(k = e.key), l = f.value.length;
		(!k || k == 8 ? 1 : (r = /^(.)\^(.*)$/.exec(m)) && (r[0] = r[2].indexOf(c) + 1) + 1 ?
			r[1] == "O" ? r[0] : r[1] == "E" ? !r[0] : accept(c, r[1]) || r[0]
			: (l = (f.value += m.substr(l, (r = /[A|9|C|\*]/i.exec(m.substr(l))) ?
			r.index : l)).length) < m.length && accept(c, m.charAt(l))) || e.preventDefault();
	}
	for(var i in !/^(.)\^(.*)$/.test(m) && (f.maxLength = m.length), {keypress: 0, keyup: 1})
		addEvent(f, i, mask);
};

	function Validate(){
		
		if(document.forms[0].nik.value == ""){
			alert("Field: NIK tidak boleh kosong ...");
			document.forms[0].nik.focus();
			return false;
		}
		
		if(document.forms[0].no_sertifikat.value == ""){
			alert("Field: No Sertifikat tidak boleh kosong ...");
			document.forms[0].no_sertifikat.focus();
			return false;
		}

		if(document.forms[0].nama_sertifikat.value == ""){
			alert("Field: Nama Sertifikat tidak boleh kosong ...");
			document.forms[0].nama_sertifikat.focus();
			return false;
		}

		if(document.forms[0].tgl_sertifikat.value == ""){
			alert("Field: Tanggal Sertifikat tidak boleh kosong ...");
			document.forms[0].tgl_sertifikat.focus();
			return false;
		}
		
		if(document.forms[0].tgl_kadaluarsa.value == ""){
			alert("Field: Tanggal Kadaluarsa Sertifikat tidak boleh kosong ...");
			document.forms[0].tgl_kadaluarsa.focus();
			return false;
		}
		
		if(document.forms[0].keterangan.value == ""){
			alert("Field: Deskripsi tidak boleh kosong ...");
			document.forms[0].keterangan.focus();
			return false;
		}

		document.forms[0].submit();
	
	}
</script>
</head>
<form name="FEmployee" method="post" action="<?=$Faction?>">
<table width="100%">
 <tr>
  <td colspan="2">
	<table width="100%">
	<tr>
	 <td colspan="2" class="line_bottom">&nbsp;&nbsp;<b>Data Sertifikasi Profesi</b></td>
	</tr>
	<tr>
	 <tr>
	  <td>&nbsp;</td>
	 <td align="right" class="line_bottom">
	 <a href="../lib/detailemp.php?show=pribadi&amp;nik=<?=$nik?>">Data Pribadi</a> &raquo; 
	 <a href="../lib/detailemp.php?show=data_umum&amp;nik=<?=$nik?>">Data Umum</a> &raquo; 
	 <a href="../lib/detailemp.php?show=pendidikan&amp;nik=<?=$nik?>"><b>Pendidikan</b></a> &raquo; 
	 <a href="../lib/detailemp.php?show=kecakapan&amp;nik=<?=$nik?>">Kecakapan</a> &raquo; 
	 <a href="../lib/detailemp.php?show=keluarga&amp;nik=<?=$nik?>">Keluarga</a> &raquo; 
	 <a href="../lib/detailemp.php?show=karir&amp;nik=<?=$nik?>">Pengalaman</a> &raquo; 
	 <a href="../lib/detailemp.php?show=organisasi&amp;nik=<?=$nik?>">Organisasi</a> 
	 </td>
	 </tr>
	</table>
  </td>
 </tr>
 <tr>
 <td>
 <table>
 <tr>
  <td><b>NIK</b></td>
  <td>: <input type="text" maxlength="10" readonly="" value="<?=$nik?>" style="font-weight:bold;"  class="text" name="nik"/> <span class="required">*</span></td>
 </tr>
 <tr>
  <td>Nomor Sertifikat</td>
  <td>: <input type="text" maxlength="30" value="<?=$row[Cert_No]?>"   size="35" class="text" name="no_sertifikat"/> <span class="required">*</span></td>
 </tr>
 <tr>
  <td>Nama Sertifikat</td>
  <td>: <input type="text" maxlength="30" value="<?=$row[Cert_Name]?>"   size="35" class="text" name="nama_sertifikat"/> <span class="required">*</span></td>
 </tr>
 <tr>
  <td>Tanggal Sertifikat</td>
  <td>: <input type="text" maxlength="30" value="<?=$row[tgl_sertifikat]?>"   size="35" class="text" name="tgl_sertifikat"/> <span class="required">*</span> <a href="javascript:calA.popup();"><img src="../../images/cal.gif" width="16" height="16" border="0" alt="Kalendar" title="Kalendar"></a></td>
 </tr>
 <tr>
  <td>Tanggal Kadaluarsa Sertifikat</td>
  <td>: <input type="text" maxlength="30" value="<?=$row[tgl_kadaluarsa]?>"   size="35" class="text" name="tgl_kadaluarsa"/> <span class="required">*</span> <a href="javascript:calB.popup();"><img src="../../images/cal.gif" width="16" height="16" border="0" alt="Kalendar" title="Kalendar"></a></td>
 </tr>
 <tr>
  <td valign="top">Deskripsi</td>
  <td valign="top">: <textarea name="keterangan" cols="35" rows="7"><?=$row[Cert_Desc]?></textarea><span class="required">*</span></td>
 </tr>
 <tr>
  <td>&nbsp;</td>
  <td>
  <input type="hidden" name="cat" value="certified" />
  <input type="hidden" name="no" value="<?=$row[No]?>" />
  <input type="button" class="button" value="Batal" onclick="Javascript:history.back()" /> <input type="button" value="<?=$Vbutton?>" onclick="Validate()" class="button" /></td>
 </tr>
</table>
</form>
</td>
</tr>
<tr>
 <td colspan="2" style="border:none;"><? include("../footer.php"); ?></td>
</tr>
</table>
<script type="text/javascript">
//<![CDATA[

var f = document.forms[0];
MaskInput(f.tgl_sertifikat,"99/99/9999");
MaskInput(f.tgl_kadaluarsa,"99/99/9999");

//]]>
</script>
<script type="text/javascript">
// script untuk popup calendar
	var calA = new calendar1(document.forms['FEmployee'].elements['tgl_sertifikat']);
	calA.year_scroll = true;
	calA.time_comp = false;

	var calB = new calendar1(document.forms['FEmployee'].elements['tgl_kadaluarsa']);
	calB.year_scroll = true;
	calB.time_comp = false;


</script>
<?
echo"</div>
	  </td>
	   </tr>
	    </table>
";
include("../menu.php");
?>
